<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>生命周期</title>
</head>
<body>
    <div id="app">
        <ul>
            <li v-for="(item,key) in list" :key="key">
                {{item}}-
            </li>
        </ul>
        <button @click="addList"> push</button>
    </div>
    <!-- vue2 -->
    <!-- <script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script> -->
    <script src="https://cdn.jsdelivr.net/npm/vue@2.6.14"></script>

    <!-- vue3 -->
    <!-- <script src="https://unpkg.com/vue@next"></script> -->
    <!-- <script src="https://cdn.jsdelivr.net/npm/vue@3.2.23/dist/"></script> -->
    
    <script>
        // vue2
        var app = new Vue({
            el:"#app",
            data:{
                list:["a"]
            },
            methods:{
                addList(){
                    this.list.push("b");
                }
            },
            beforeCreate() {
                console.log("我在创建之前被调用1");
            },
            created() {
                console.log("我在创建之后被调用2");
            },
            beforeMount() {
                console.log("我在挂在之前被调用3");
            },
            mounted() {
                console.log("我在挂在之前被调用4");
            },
            beforeUpdate() {
                console.log("我在更新之后被调用5");
            },
            updated() {
                console.log("我在更新之后被调用6");
            },

        })

        // vue3
        // const HelloVueApp = {
        //     data() {
        //         return {
        //             list:["a"]

        //         }
        //     },
            
        // };
        // Vue.createApp(HelloVueApp).mount("#app")
    </script>
</body>
</html>